package com.cmsky.open.core.util;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
/**
 * 后台处理错误工具类
 * @author jandyfish
 *
 */
public class AdminErrorUtil {
	private static Logger logger = Logger.getLogger("admin.error");
	/**
	 * 后台页面访问错误
	 * @param cls
	 * @param method
	 * @param request
	 * @param errorTitle
	 * @param errorMsg
	 * @return
	 */
	public static ModelAndView getAdminErrorView(Class cls,String method,
			HttpServletRequest request,
			String errorTitle,String errorMsg){
		ModelAndView view = new ModelAndView("/admin/error");
		StringBuffer buffer = new StringBuffer(cls.getName());
		buffer.append("<|>").append(method);
		buffer.append("<|>").append(request.getHeader("Referer"));
		buffer.append("<|>").append(request.getRequestURI());
		buffer.append("<|>").append(request.getQueryString());
		buffer.append("<|>").append(errorTitle);
		buffer.append("<|>").append(errorMsg);
		logger.warn(buffer.toString());
		view.addObject("errorTitle",errorTitle);
		view.addObject("errorMsg",errorMsg);
		return view;
	}
}
